<script setup lang="ts">
import type { Family } from '../../../types/FamilyHome'


const props = defineProps<{
  family: Family
}>()

const emit = defineEmits<{
  apply: [familyId: string]
}>()

function handleCardClick() {
  console.log('查看家族详情')
}

function handleApply() {
  emit('apply', props.family.id)
}
</script>

<template>
  <el-card class="family-card" shadow="hover" @click="handleCardClick">
    <div class="card-content">
      <div class="family-avatar">
        <img :src="family.avatar" :alt="family.name" />
      </div>
      <div class="family-info">
        <h4 class="family-name">{{ family.name }}</h4>
        <p class="family-location">{{ family.location }}</p>
        <p class="family-description">{{ family.description }}</p>
        <div class="family-stats">
          <span class="member-count">成员: {{ family.memberCount }}人</span>
        </div>
      </div>
      <div class="card-actions">
        <el-button 
          type="primary" 
          size="small" 
          class="apply-btn"
          @click.stop="handleApply"
        >
          申请加入
        </el-button>
      </div>
    </div>
  </el-card>
</template>

<style lang="scss" scoped>
.family-card {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  cursor: pointer;
  transition: all 0.3s ease;
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 12px;
  overflow: hidden;
  
  &:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    border-color: #88a68e;
  }
  
  :deep(.el-card__body) {
    padding: 0;
  }
}

.card-content {
  display: flex;
  padding: 20px;
  gap: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(250, 248, 243, 0.9) 100%);
}

.family-avatar {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid #d4af37;
  
  img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

.family-info {
  flex: 1;
  min-width: 0;
}

.family-name {
  font-family: 'KaiTi', '楷体', serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: #5d4037;
  margin: 0 0 8px 0;
  line-height: 1.3;
}

.family-location {
  font-size: 0.9rem;
  color: #88a68e;
  margin: 0 0 8px 0;
  font-weight: 500;
}

.family-description {
  font-size: 0.85rem;
  color: #666;
  margin: 0 0 12px 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.family-stats {
  font-size: 0.8rem;
  color: #999;
}

.member-count {
  background: rgba(136, 166, 142, 0.1);
  padding: 2px 8px;
  border-radius: 10px;
  color: #88a68e;
  font-weight: 500;
}

.card-actions {
  display: flex;
  align-items: center;
}

.apply-btn {
  background: linear-gradient(135deg, #88a68e 0%, #6b8e6b 100%);
  border: none;
  border-radius: 15px;
  padding: 8px 16px;
  font-size: 0.85rem;
  transition: all 0.3s ease;
  
  &:hover {
    background: linear-gradient(135deg, #6b8e6b 0%, #5a7a5a 100%);
    transform: scale(1.05);
  }
}

@media (max-width: 768px) {
  .card-content {
    padding: 16px;
    gap: 12px;
  }
  
  .family-avatar {
    width: 60px;
    height: 60px;
  }
  
  .family-name {
    font-size: 1.1rem;
  }
  
  .family-location {
    font-size: 0.85rem;
  }
  
  .family-description {
    font-size: 0.8rem;
  }
}
</style>
